home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 October / Chip Ekim 2003.iso / prog / code / contr / setup.exe / Disk1 / data1.cab / Configuration_En / Commands / Source Formatting.js < prev    next >
Encoding:
JavaScript  |  2003-07-18  |  1.2 KB  |  40 lines

  1. // Copyright 1998, 1999, 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2. //-----------------------------------------------------
  3. //
  4. // Source Formatting.js
  5. //
  6. // This file contains the implementation to fire off the Dreamweaver
  7. // source formatter.
  8.  
  9. function canAcceptCommand()
  10. {
  11.   retVal = false;
  12.   if (dw.getDocumentDOM() && (dw.getDocumentDOM().getParseMode() == 'html' || dw.getDocumentDOM().getParseMode() == 'xml') && (dw.getFocus() == 'document' || dw.getFocus(true) == 'html' || dw.getFocus() == 'textView')){
  13.     retVal = true;
  14.   }
  15.   return retVal;
  16. }
  17.  
  18. // formatSource()
  19. //
  20. // This routine kicks off the Dreamweaver source formatter
  21. // on the entire document by "touching" the HTML child tag
  22. // innerHTML properties.
  23. // 
  24. function formatSource(dom)
  25. {
  26.    if (dom) { 
  27.       if (dom.getParseMode() == 'xml')
  28.           dom.synchronizeDocument();
  29.    }
  30.    else if (dw.getDocumentDOM("document").getParseMode() == 'xml')
  31.       dw.getDocumentDOM("document").synchronizeDocument();
  32.       
  33.    var root      = dom || dreamweaver.getDocumentDOM("document");
  34.    var outerHTML = root.documentElement.outerHTML;
  35.  
  36.    root.formatRange(0, outerHTML.length);
  37.    
  38.    return;         
  39. }
  40.